package com.iot.common.enums;

public enum LanguageType {

    CHINESE(1, "zh-CN", "中文"),
    ENGLISH(2, "en-US","英文"),
            ;

    private final int number;
    private final String character;
    private final String name;

    LanguageType(int number, String character, String name) {
        this.number = number;
        this.character = character;
        this.name = name;
    }

    public int getNumber() {
        return number;
    }

    public String getCharacter() {
        return character;
    }

    public static String getCharacter(int number) {
        for (LanguageType nce : LanguageType.values()) {
            if (nce.getNumber() == number) {
                return nce.getCharacter();
            }
        }
        throw new IllegalArgumentException("未知的数字: " + number);
    }

    public String getName() {
        return name;
    }

    // 通过数字获取对应的枚举
    public static LanguageType fromNumber(int number) {
        for (LanguageType nce : LanguageType.values()) {
            if (nce.getNumber() == number) {
                return nce;
            }
        }
        throw new IllegalArgumentException("未知的数字: " + number);
    }
}
